package com.mk.settlement.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.mk.settlement.mappers.SettlementOrderMapper;
import com.mk.settlement.model.SettlementOrder;

/**
 * 结算基础订单服务类.
 * 
 * @author chuaiqing.
 *
 */
@Service
public class SettlementOrderService {
    
    /**
     * 日志对象
     */
    private Logger log = LoggerFactory.getLogger(SettlementOrderService.class);
    
    /**
     * 注入SettlementOrderMapper.
     */
    @Autowired
    private SettlementOrderMapper settlementOrderMapper;
    
    /**
     * 更新结算订单数据.
     * @param record
     * @return
     */
    public int updateByPrimaryKeySelective(SettlementOrder record) {
        log.info("准备更新结算订单数据......");
        log.info(JSON.toJSONString(record));
        int updateRows = -1;
        try {
            updateRows = settlementOrderMapper.updateByPrimaryKeySelective(record);
            log.info("成功更新{}条结算订单数据.", updateRows);
        } catch (Exception e) {
            log.error("更新结算订单数据出错：{}", e.getLocalizedMessage());
        }
        return updateRows;
    }
    
    /**
     * 删除结算订单.
     * @param id
     * 参数：结算订单数据id.
     * @return
     */
    public int deleteByPrimaryKey(Long id) {
        log.info("准备删除主键为{}的结算订单数据......", id);
        int deleteRows = -1;
        try {
            deleteRows = settlementOrderMapper.deleteByPrimaryKey(id);
            log.info("成功删除{}条结算订单数据.", deleteRows);
        } catch (Exception e) {
            log.error("删除结算订单数据出错：{}", e.getLocalizedMessage());
        }
        return deleteRows;
    }
}
